package com.thiscc.sum.utils;

import java.util.List;

import net.sf.json.JSONArray;

import com.mongodb.DBObject;

public class ShareUtils {

    /**
     * 解析我的分享表里的数据
     * @param list
     * @return
     */
    public static String getData(List<DBObject> list) {

        JSONArray resultArray = new JSONArray();

        String s_stime = null; //分享时间
        String z_ztime = null; //总结发送的时间
        String s_time = null;
        List<DBObject> l_address = null;
        JSONArray array = new JSONArray();

        for (DBObject DBO_replay : list) {

            s_stime = DateUtils.dateToString(DBObjectUtils.getDate(DBO_replay, "stime"), DateUtils.DATE_FORMAT_SS);
            z_ztime = DateUtils.dateToString(DBObjectUtils.getDate(DBO_replay, "ztime"), DateUtils.DATE_FORMAT_SS);

            DBO_replay.put("stime", s_stime);
            DBO_replay.put("ztime", z_ztime);

            DBO_replay.removeField("_id");

            l_address = DBObjectUtils.getList(DBO_replay, "address");

            for (DBObject addressBean : l_address) {

                s_time = DateUtils.dateToString(DBObjectUtils.getDate(DBO_replay, "time"), DateUtils.DATE_FORMAT_SS);
                addressBean.put("time", s_time);
                array.add(addressBean);
            }

            DBO_replay.put("address", array);
            resultArray.add(DBO_replay);
        }

        return resultArray.toString();
    }
}
